#region Imported Namespaces


#endregion


#region Imported Namespaces


using System.Diagnostics;
using System.Windows.Input;

using WtfManager.Framework;
using WtfManager.HierarchicalData;


#endregion


namespace WtfManager.FileManager
{
  ///<summary>
  ///Creates and manages a file system hierarchy.
  ///</summary>
  public class FileSystem: ExtensibleService, IHierarchyExtension
  {
    #region Fields


    public static readonly RoutedUICommand ShowShellContextMenuCommand = new RoutedUICommand("Show Shell Context Menu",
                                                                                         "ShowShellContextMenuCommand",
                                                                                         typeof(FileSystem));

    private MyComputer _myComputer;


    #endregion


    #region Constructors/Finalizers


    internal FileSystem()
    {
    }


    #endregion


    #region Properties/Indexers


    /// <summary>
    /// Gets a description of a service.
    /// </summary>
    public override string Description
    {
      get
      {
        return "Creates and manages a file system hierarchy.";
      }
    }

    ///<summary>
    /// Gets a hierarchy that should be added to <see cref="DataHierarchyService"/> service.
    ///</summary>
    TreeItem IHierarchyExtension.Hierarchy
    {
      get
      {
        Debug.Assert(IsInitialized, "FileSystemService is not yet initialized.");

        return _myComputer;
      }
    }


    ///<summary>
    /// Gets file system root node.
    ///</summary>
    public MyComputer MyComputer
    {
      get
      {
        Debug.Assert(IsInitialized, "FileSystemService is not yet initialized.");

        return _myComputer;
      }
    }


    /// <summary>
    /// Gets a name of a service.
    /// </summary>
    public override string Name
    {
      get
      {
        return "File System";
      }
    }


    #endregion


    #region Methods


    protected override void OnStateChnaged()
    {
    }


    protected override FrameworkComponentState OnLoad()
    {
      _myComputer = new MyComputer();

      return FrameworkComponentState.Loaded;
    }


    protected override void OnUnload()
    {
      _myComputer = null;
    }


    protected override void OnExtensionAdded(Service extension)
    {
    }


    public override bool IsExtension(Service extension)
    {
      return false;
    }


    protected override void OnExtensionRemoved(Service extension)
    {
    }


    protected override FrameworkComponentState OnInitialize()
    {
      return FrameworkComponentState.Initialized;
    }


    #endregion
  }
}